function AccountsFilter(fromCookie) {

	var self = this;
	this.srcDstList = [];
	if(fromCookie) {
		var srcDstCookie = $.cookie('trFilterSrcDstList');
		if(srcDstCookie != null) {
			$.each(JSON.parse(srcDstCookie), function(index, srcDst) {
				self.srcDstList.push({ srcId: srcDst.srcId, dstId: srcDst.dstId });
			});
		}
	}

	this.add = function(srcAccount, dstAccount) {
		var exists = false;
		$.each(this.srcDstList, function(index, srcDst) {
			if(srcDst.srcId === srcAccount.id && srcDst.dstId === dstAccount.id) {
				exists = true;
				return false;
			}
		});
		if(!exists) {
			this.srcDstList.push({ srcId: srcAccount.id, dstId: dstAccount.id });
			$.cookie('trFilterSrcDstList', JSON.stringify(this.srcDstList));
			$(this).trigger('change');
			return true;
		}
		return false;
	};

	this.remove = function(index) {
		if(this.srcDstList.length > index && index >= 0) {
			this.srcDstList.splice(index, 1);
			$.cookie('trFilterSrcDstList', JSON.stringify(this.srcDstList));
			$(this).trigger('change');
			return true;
		}
		return false;
	};

	this.filter = function(accountsMap) {
		var indexToRemove = [];
		$.each(this.srcDstList, function(index, srcDst) {
			if(!(srcDst.srcId in accountsMap) || !(srcDst.dstId in accountsMap)) {
				indexToRemove.unshift(index);
			}
		});
		$.each(indexToRemove, function(i, index) {
			this.srcDstList.splice(index, 1);
		});
		if(indexToRemove.length > 0) {
			$.cookie('trFilterSrcDstList', JSON.stringify(this.srcDstList));
			$(this).trigger('change');
		}
	};

	this.getValue = function() {
		return Object.keys(this.srcDstList);
	};
};